import 'dart:convert';
import 'package:ichinesereader/models/book/MaxScore.dart';

List<AssignmentStudentDetail> assignmentStudentDetailFromJson(String str) =>
    List<AssignmentStudentDetail>.from(
        json.decode(str).map((x) => AssignmentStudentDetail.fromJson(x)));

String assignmentStudentDetailToJson(List<AssignmentStudentDetail> data) =>
    json.encode(List<dynamic>.from(data.map((x) => x.toJson())));

class AssignmentStudentDetail {
  AssignmentStudentDetail({
    this.maxQuixAttempt,
    this.bookImageUrl,
    this.bookName,
    this.bookId,
    this.complete,
    this.maxScore,
    this.percentage,
    this.writing,
    this.recording,
    this.englishBookTitle,
    this.writingReport,
    this.recordingReport,
    this.readCount,
    this.quizCount,
  });

  MaxScore? maxQuixAttempt;
  String? bookImageUrl;
  String? bookName;
  String? bookId;
  bool? complete;
  int? maxScore;
  int? percentage;
  String? writing;
  String? recording;
  String? englishBookTitle;
  IngReport? writingReport;
  IngReport? recordingReport;
  int? readCount;
  int? quizCount;

  factory AssignmentStudentDetail.fromJson(Map<String, dynamic> json) =>
      AssignmentStudentDetail(
        maxQuixAttempt: json["maxQuixAttempt"] != null
            ? MaxScore.fromJson(json["maxQuixAttempt"])
            : null,
        bookImageUrl: json["bookImageUrl"],
        bookName: json["bookName"],
        bookId: json["bookId"],
        complete: json["complete"],
        maxScore: json["maxScore"],
        percentage: json["percentage"],
        writing: json["writing"],
        recording: json["recording"],
        englishBookTitle: json["englishBookTitle"],
        writingReport: json["writingReport"] != null
            ? IngReport.fromJson(json["writingReport"])
            : null,
        recordingReport: json["recordingReport"] != null
            ? IngReport.fromJson(json["recordingReport"])
            : null,
        readCount: json["readCount"],
        quizCount: json["quizCount"],
      );

  Map<String, dynamic> toJson() => {
        "maxQuixAttempt":
            maxQuixAttempt != null ? maxQuixAttempt!.toJson() : null,
        "bookImageUrl": bookImageUrl,
        "bookName": bookName,
        "bookId": bookId,
        "complete": complete,
        "maxScore": maxScore,
        "percentage": percentage,
        "writing": writing,
        "recording": recording,
        "englishBookTitle": englishBookTitle,
        "writingReport": writingReport != null ? writingReport!.toJson() : null,
        "recordingReport":
            recordingReport != null ? recordingReport!.toJson() : null,
        "readCount": readCount,
        "quizCount": quizCount,
      };
}

class IngReport {
  IngReport({
    this.comment,
    this.grade,
    this.status,
  });

  String? comment;
  String? grade;
  String? status;

  factory IngReport.fromJson(Map<String, dynamic> json) => IngReport(
        comment: json["comment"],
        grade: json["grade"],
        status: json["status"],
      );

  Map<String, dynamic> toJson() => {
        "comment": comment,
        "grade": grade,
        "status": status,
      };
}
